<template>
  <div>
  <el-card class="box-card">
    <el-table
      :data="tableData"
      border
      stripe
    >
      <el-table-column type="selection" width="55" align="center"></el-table-column>
      <el-table-column prop="nid" label="学号" align="center"></el-table-column>
      <el-table-column prop="name" label="姓名" align="center"></el-table-column>
      <el-table-column prop="sex" label="性别" align="center"></el-table-column>
      <el-table-column prop="college" label="学院" align="center"></el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope" class="active">
          <el-button @click="editData(scope.row)" type="primary" icon="el-icon-edit" circle></el-button>
          <el-button @click="removeData(scope.row.id)" type="danger" icon="el-icon-delete" circle></el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-row :gutter="20">
      <el-col :span="6" :offset="12">
        <div class="block">
          <el-pagination
            background
            layout="total, prev, next, jumper, pager"
          ></el-pagination>
        </div>
      </el-col>
    </el-row>
  </el-card>
  </div>
</template>

<script>
export default {
  name: "getTest",
  data() {
    return {
      tableData: [], //存放从后端传来的数据
    };
  },
  mounted() {
    this.fetchdata()
  },
  methods: {
    //获取后端数据
    fetchdata() {
      axios
        .get("http://chongxian-wang:9092/newsController/getAllNews")
        .then(
          response => {
            this.tableData = response.data;
          },
          response => {
            console.log("error");
            alert("请求失败");
          }
        );
    },
  }
}
</script>

<style scoped>

</style>
